Fixed a bug and added warn statements