Fixed promise error handling