can you make this code run more efficiently?