Changed var names + added checks