code refactoring - removed redundant flex check code