remove unnecessary instance variables
improve error handling