simplified, removed all error handling
removed unneeded variables