some code refactoring for better maintanenece and oprtability