Added error check

Get function checks whether queue is not empty