Tested. Added return codes. Added enum for error codes