adding block()
added exception handling