Changed the function addressing and moved the vardata before its check