more optimization, still needs work