adds validation, cleans up js and templates