Changed implementation to throw exception in ruby