starting error checking but not working completely