Rearranging Code + Implementing Input Validation