replaced error log to prepare and added option debug