Added support till 999, cleaned code