cleaned up
code optimized slightly