various attempts at optimization