code has been refactored and moved to external module