hardens user controller actions against invalid input, refactors for improved readability