Made class more robust