Fixed the final bug with the returning error code