better error handling, finished manual parsing