Fixed and moved code