Improve error message

Signed-off-by: Aniket Pant <me@aniketpant.com>
Decouple code and add docs

Signed-off-by: Aniket Pant <me@aniketpant.com>