Added better error checking

Signed-off-by: AlphaMusk <alphamusk@networkpulse.com>