update code for better performance