Fix bug with 500 internal error