Updated to work better with require js