refactor to avoid document ready call