followed some suggested code optimizations