updated with optimizations