attempt at optimization