Cleaned code

Less css manipulation, use switch instead of multiple ifs, throw exception for invalid value