fixing some bug in the backend