Added check if the data is empty
- added unit testing to cover this check