refactored base js