=added error handler
=Added format function