Implemented error returning