added pattern guards to try..with..