Replaced file operation with DB