adjusting code for errors