Removed unused variable; Added reject on error