bug fixing updated code