Working code with possible hacky solution