Error checks added