modified code for better performance