cleaned pointless code and error handling