refactored to remove unnecessary js code