Simplified by following ruby coding style