fixed typo causing compiler error
optimized code