Suggested pull request changes applied.

- Code made to be more reusable.
- Unnecessary size checking removed.