Refactored javascript bob